#include "../../common/detail.hpp"
#include "../../client/client.hpp"
#include <chrono>
#include <iostream>
#include <thread>

void addResponse(const Json::Value& result)
{
    std::cout<<"result :"<<result.asInt()<<std::endl;

}
int main()
{


    qiangsir::client::RpcClient client(true,"127.0.0.1",8080);

    Json::Value params, result;
    params["num1"] = 11;
    params["num2"] = 33;
    bool ret = client.call("Add",params,result);
    if (ret != false)
    {
        std::cout << "result:" << result.asInt() << std::endl;
    }
    DLOG("同步rpc调用完毕");
    std::future<Json::Value> res_future;
    params["num1"] = 33;
    params["num2"] = 44;
    ret = client.call("Add",params,res_future);
    if (ret != false)
    {
        result = res_future.get();
        std::cout << "result:" << result.asInt() << std::endl;
    }

    DLOG("异步rpc调用完毕");

    params["num1"] = 44;
    params["num2"] = 55;
    ret = client.call("Add",params,addResponse);

    DLOG("回调rpc调用完毕-----------------");

    std::this_thread::sleep_for(std::chrono::seconds(3));

    return 0;
}
